package com.hjc.springbootmovies.controller;

import com.hjc.springbootmovies.entity.*;
import com.hjc.springbootmovies.service.Impl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/5
 * Time: 14:17
 * To change this template use File | Settings | File Templates.
 */
@RestController
@RequestMapping("/gson")
public class GsonController {
    @Autowired
    private FsortServiceImpl fsortService;
    @Autowired
    private FimlServiceImpl fimlService;
    @Autowired
    private HallServiceImpl hallService;
    @Autowired
    private EmpServiceImpl empService;
    @Autowired
    private BoradServiceImpl boradService;
    @Autowired
    private SaleServiceImpl saleService;
    @Autowired
    private MoneyServiceImpl moneyService;

    @GetMapping("fsortGson")
    public List<ModelFsort> queryFsort(){
        return fsortService.queryFsort();
    }

    @GetMapping("updateFsort")
    public ModelFsort queryById(int sid){ return fsortService.queryById(sid); }

    @GetMapping("fimlGson")
    public List<ModelFiml> queryFiml(int fflag){
        return fimlService.queryFiml(fflag);
    }

    @GetMapping("hallGson")
    public List<ModelHall> queryHall(){
        return hallService.queryHall();
    }

    @GetMapping("hallbroadGson")
    public List<ModelHall> queryHallBroad(HttpServletRequest request){
        int fid = (int)request.getSession().getAttribute("fid");
        return hallService.queryByBroad(fid);
    }

    @GetMapping("empGson")
    public List<ModelEmp> queryEmp(){
        return empService.queryEmp();
    }

    @GetMapping("boradGson")
    public List<ModelBroad> queryBorad(){
        return boradService.queryBorad();
    }

    @GetMapping("saleGson")
    public List<ModelSale> querySale(){
        return saleService.querySale();
    }

    @GetMapping("salemzwGson")
    public List<ModelSale> querySaleMzw(HttpServletRequest request){
        int tid = (int)request.getSession().getAttribute("tid");
        int fid = (int)request.getSession().getAttribute("fid");
        return saleService.queryMzw(tid,fid);
    }

    @GetMapping("saleGson2")
    public List<ModelSale> querySale2(Integer xid){
        return saleService.queryById2(xid);
    }

    @GetMapping("moneyGson")
    public List<ModelMoney> queryMoney(Integer xid){
        return moneyService.queryAll();
    }

}
